{include file="public/header" /}
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong><span class="icon-key"></span> 添加管理员</strong></div>
    <div class="body-content">
        <form method="post" id="from" class="form-x" action="">
            <div class="form-group">
                <div class="label">
                    <label>权限组 ：</label>
                </div>
                <div class="field">
                    <select name="role_id" class="input w50">
                        <option value="0">请选择权限组</option>

                        {foreach name='list' item='val'}
                        <option value="{$val.id}"> {$val.role_name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label for="sitename">管理员账号：</label>
                </div>
                <div class="field">
                    <label style="line-height:33px;">
                        <input type="text" class="input w50" name="username" value=""  data-validate="required:账号不能为空" />
                    </label>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label for="sitename">密码：</label>
                </div>
                <div class="field">
                    <input type="password" class="input w50" name="password" size="50" placeholder="请填写密码" data-validate="required:请输入密码,密码长度不能小于6位" />
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label for="sitename"> 确认密码：</label>
                </div>
                <div class="field">
                    <input type="password" class="input w50" name="repassword" size="50" placeholder="请再次填写密码" data-validate="required:请再次输入密码,repeat#password:请再次输入密码" />
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <a class="button bg-main icon-check-square-o"  onclick="submit()" type="submit"> 提交</a>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
       function submit(){
           var data=new FormData($("#from")[0]);
           $.ajax({
               type:"post",
               url:"{:U('admin/add')}",
               data:data,
               dataType:"json",
               processData:false,
               contentType:false,
               cache:false,
               success:function(rs){
                   if(rs.res==1 && rs.data.url!= undefined){
                       layer.msg(rs.msg, {icon:1}, function(){
                           window.location=rs.data.url;
                       });
                   }else{
                       layer.msg(rs.msg);
                   }
               }
           });
       }

</script>

{include file="public/footer" /}